<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8" />
    <title>消息通知-{eyou:global name='web_name' /}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <link href="{eyou:global name='web_cmspath'/}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    {eyou:static file="users/skin/css/eyoucms.css"/}
    <!-- 新样式 2020-11-25 -->
    {eyou:static file="users/skin/css/element/index.css" /}
    {eyou:static file="users/skin/css/e-user.css" /}
    {eyou:static file="users/skin/fonts/css/font-awesome.css" /}
    {eyou:include file="users/skin/css/diy_css.htm"/}
    {eyou:static file="/public/static/common/js/jquery.min.js"/}
    {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
    {eyou:static file="/public/static/common/js/tag_global.js"/}
</head>

<body class="centre">
<!-- 头部 -->
{eyou:include file="users/users_header.htm" /}
<!-- END -->
<div class="breadcrumbs"></div>
<div class="ey-body-bg">
    <div class="ey-body pd0">
        <div class="ey-container w1226">
			<!-- 侧边 -->
			{eyou:include file="users/users_left.htm" /}
			<!-- END -->
			<!-- 中部 -->
			<div class="ey-con fr" >
				<div class="el-main main-bg xin_mian">
					<!-- 顶部导航栏 -->
                    <div class="el-row shop-oper">
                        <h1 class="title">消息通知</h1>
                    </div>
					<!-- END -->

					<div class="el-table message-list mt10" style="width: 100%;" id="questions">

						<ul class="services-list">
							{empty name="$eyou.field.data"}
								<div class="cell null-data pt100 tc">
								   <span class="mb10"><img id='litpic_img'  src="{eyou:static file='users/skin/images/null-data.png' /}"/></span>
								 </div>
							{else/}
								{eyou:volist name="$eyou.field.data" id="vo"}
                                	<li class="con {neq name='$vo.is_read' value='1'}weidu unread_state_{$vo.id}{/neq}">
                                        <div class="title_n">
                                            <label class="checkbox-label release-checkbox">
                                                <span> &nbsp; </span>
                                                <input class="checkbox" type="checkbox" name="ids[]" value="{$vo.id}">
                                                <span class="check-mark top7"></span>
                                            </label>
                                            <span class="read-state_y">[已读]</span>
                                            <span class="read-state_w">[未读]</span>
                                            <a href="javascript:void(0);" data-id="{$vo.id}" data-title="{$vo.title}" data-content="{$vo.remark}" class="open-content">
                                                {$vo.title}
                                            </a>
                                            <span class="time_n open-content" data-id="{$vo.id}">{$vo.add_time|date='Y-m-d H:i:s',###} <i class="fa fa-angle-down"></i></span>
                                        </div>
                                		<div class="service-content">
                                			<div class="service-info-text">
                                                <p>{$vo.remark}</p>
                                			</div>
                                		</div>
                                	</li>
								{/eyou:volist}
							{/empty}
						</ul>
                        {notempty name="$eyou.field.data"}
                        
                        <div class="message-footer">
                            <label class="checkbox-label release-checkbox notice-checkbox">
                            	<span> &nbsp; </span>
                            	<input class="checkbox" type="checkbox" onclick="javascript:$('input[name*=ids]').prop('checked',this.checked);">
                            	<span class="check-mark"></span>
                            </label>
                            <a id="del_btn" class="el-button el-button--default is-disabled el-button--small" data-disabled='1' href="javascript:void(0);" onclick="BatchDelData(this, 'ids');" data-url="{$eyou.field.delurl}">
                                删除
                            </a>
                            <a id="signRead_btn" class="el-button el-button--default is-disabled el-button--small" data-disabled='1' href="javascript:void(0);" onclick="BatchReadData(this, 'ids');">
                                标记已读
                            </a>
                        </div>
                        {/notempty}
					</div>
                    {notempty name="$eyou.field.data"}
					<div style="text-align: center;">
						{$page}
						{eyou:if condition="!empty($pager->totalRows)"}
						<div class="fytotal">{:sprintf(foreign_lang('page5'), $pager->totalPages, $pager->totalRows)}</div>
						{/eyou:if}
					</div>
                    {/notempty}
				</div>
			<!-- END -->
			</div>

        </div>
    </div>
</div>


<script type="text/javascript">
   //显示消息内容、手风琴效果
   $(function() {
       $(".open-content").on("click", function() {
           var next = $(this).parent('.title_n').next('.service-content');
           var icon = $(this).parent('.title_n').find('i');
           var par=$(this).parent('.title_n');
           next.slideToggle('fade');
           if (icon.hasClass('fa fa-angle-down')) {
               icon.removeClass('fa fa-angle-down');
               icon.addClass('fa fa-angle-up');
           } else {
               icon.removeClass('fa fa-angle-up');
               icon.addClass('fa fa-angle-down');
           }
           
           if(!par.hasClass('cur')){
               par.addClass('cur');               
           }else{
                par.removeClass('cur');
           }
           
           $('.service-content').not(next).slideUp('fast'); //不是当前点击的内容全部向上收起
           $(".message-list>ul>li>.title_n>.time_n").children('i').not(icon).attr('class','fa fa-angle-down');
           $('.title_n').not(par).removeClass('cur');

           read_notice($(this));

           return false;
       });
   });

    $(function(){
        $('input[type=checkbox]').click(function(){
            if ($('input[name*=ids]:checked').length > 0) {
                $('#del_btn').removeClass('is-disabled').attr('data-disabled', 0);
                $('#signRead_btn').removeClass('is-disabled').attr('data-disabled', 0);
            } else {
                $('#del_btn').addClass('is-disabled').attr('data-disabled', 1);
                $('#signRead_btn').addClass('is-disabled').attr('data-disabled', 1);
            }
        });
    });

    function read_notice(obj){
        var id=$(obj).attr('data-id');

        $.ajax({
            url: "{eyou:url link='api/Ajax/notice_read'/}",
            data: {id:id,_ajax:1},
            type:'get',
            dataType:'json',
            success:function(res){
                if(res.code == 1) {
                    $('.unread_state_' + id).removeClass('weidu');
                    $('.unread_state_' + id).removeClass('unread_state_' + id);
                }
            }
        });
    }

    // 删除单个通知
    function DelData(obj) {
        layer.confirm('是否删除该消息？', {
            title: false,
            btn: ['是','否'] //按钮
        }, function(){
            layer_loading('正在处理');
            // 确定
            $.ajax({
                type: "POST",
                url: $(obj).attr('data-url'),
                data: {del_id:$(obj).attr('data-id'),_ajax:1},
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if(res.code == 1){
                        layer.msg(res.msg, {icon: 6,time:1500});
                        window.location.reload();
                    }else{
                        showErrorAlert(res.msg);
                    }
                },
                error:function(e){
                    layer.closeAll();
                    showErrorAlert(e.responseText);
                }
            });
        }, function(index){
            layer.close(index);
        });
    }
    // 批量删除通知
    function BatchDelData(obj, name) {
        var data_disabled = $(obj).attr('data-disabled');
        if (1 == data_disabled) {
            return false;
        }
        
        var a = [];
        $('input[name^='+name+']').each(function(i,o){
            if($(o).is(':checked')){
                a.push($(o).val());
            }
        })
        if(a.length == 0){
            showErrorAlert(ey_foreign_system7);
            return;
        }
        // 删除按钮
        layer.confirm('确认批量删除消息？', {
            title: false,
            btn: [ey_foreign_system2, ey_foreign_system3] //按钮
        }, function () {
            layer_loading('正在处理');
            $.ajax({
                type: "POST",
                url: $(obj).attr('data-url'),
                data: {del_id:a,_ajax:1},
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if(res.code == 1){
                        layer.msg(res.msg, {icon: 6,time:1500});
                        window.location.reload();
                    }else{
                        showErrorAlert(res.msg);
                    }
                },
                error:function(e){
                    layer.closeAll();
                    showErrorAlert(e.responseText);
                }
            });
        }, function (index) {
            layer.closeAll(index);
        });
    }

    // 批量已读
    function BatchReadData(obj, name) {
        var data_disabled = $(obj).attr('data-disabled');
        if (1 == data_disabled) {
            return false;
        }
        
        var a = [];
        $('input[name^='+name+']').each(function(i,o){
            if($(o).is(':checked')){
                a.push($(o).val());
            }
        })
        if(a.length == 0){
            showErrorAlert(ey_foreign_system7);
            return;
        }

        layer.confirm('确认批量标记已读？', {
            title: false,
            btn: [ey_foreign_system2, ey_foreign_system3] //按钮
        }, function () {
            layer_loading('正在处理');
            $.ajax({
                type: "POST",
                url: "{eyou:url link='user/UsersNotice/batch_read'/}",
                data: {del_id:a,_ajax:1},
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if(res.code == 1){
                        layer.msg(res.msg, {icon: 6,time:1500});
                        window.location.reload();
                    }else{
                        showErrorAlert(res.msg);
                    }
                },
                error:function(e){
                    layer.closeAll();
                    showErrorAlert(e.responseText);
                }
            });
        }, function (index) {
            layer.closeAll(index);
        });
    }


    // 所有已读
    function ReadAllData(obj, name) {
        layer.confirm('确认全部标记已读？', {
            title: false,
            btn: [ey_foreign_system2, ey_foreign_system3] //按钮
        }, function () {
            layer_loading('正在处理');
            $.ajax({
                type: "POST",
                url: "{eyou:url link='user/UsersNotice/batch_read_all'/}",
                data: {_ajax:1},
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if(res.code == 1){
                        layer.msg(res.msg, {icon: 6,time:1500});
                        window.location.reload();
                    }else{
                        showErrorAlert(res.msg);
                    }
                },
                error:function(e){
                    layer.closeAll();
                    showErrorAlert(e.responseText);
                }
            });
        }, function (index) {
            layer.closeAll(index);
        });
    }

    // 删除所有通知
    function DelAllData(obj, name) {
        // 删除按钮
        layer.confirm('确认删除所有消息？', {
            title: false,
            btn: [ey_foreign_system2, ey_foreign_system3] //按钮
        }, function () {
            layer_loading('正在处理');
            $.ajax({
                type: "POST",
                url: "{eyou:url link='user/UsersNotice/del_all'/}",
                data: {_ajax:1},
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if(res.code == 1){
                        layer.msg(res.msg, {icon: 6,time:1500});
                        window.location.reload();
                    }else{
                        showErrorAlert(res.msg);
                    }
                },
                error:function(e){
                    layer.closeAll();
                    showErrorAlert(e.responseText);
                }
            });
        }, function (index) {
            layer.closeAll(index);
        });
    }
</script>
{eyou:include file="users/users_footer.htm" /}
<!-- END -->